The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
META.yml 24
README 11
lib/Data/GUID.pm 2645
t/basic.t 1716
4 files changed (This is a version diff) 4666
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Data-GUID
-version:            0.045
+version:            0.046
 abstract:           globally unique identifiers
 author:
     - Ricardo Signes <rjbs@cpan.org>
@@ -8,6 +8,8 @@ license:            perl
 distribution_type:  module
 configure_requires:
     ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
 requires:
     Data::UUID:     1.148
     Sub::Exporter:  0.9
@@ -19,7 +21,7 @@ no_index:
     directory:
         - t
         - inc
-generated_by:       ExtUtils::MakeMaker version 6.48
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
     url:      http://module-build.sourceforge.net/META-spec-v1.4.html
     version:  1.4
@@ -1,4 +1,4 @@
-Data-GUID 0.045
+Data-GUID 0.046
 
 Data::GUID provides an alternate interface to Data::UUID for creating and
 comparing globally unique IDs.
@@ -13,11 +13,11 @@ Data::GUID - globally unique identifiers
 
 =head1 VERSION
 
-version 0.045
+version 0.046
 
 =cut
 
-our $VERSION = '0.045';
+our $VERSION = '0.046';
 
 =head1 SYNOPSIS
 
@@ -40,7 +40,7 @@ identifiers.
 
 =head1 GETTING A NEW GUID
 
-=head2 C< new >
+=head2 new
 
   my $guid = Data::GUID->new;
 
@@ -60,20 +60,20 @@ sub new {
 These method returns a new Data::GUID object for the given GUID value.  In all
 cases, these methods throw an exception if given invalid input.
 
-=head2 C< from_string >
+=head2 from_string
 
   my $guid = Data::GUID->from_string("B0470602-A64B-11DA-8632-93EBF1C0E05A");
 
-=head2 C< from_hex >
+=head2 from_hex
 
   # note that a hex guid is a guid string without hyphens and with a leading 0x
   my $guid = Data::GUID->from_hex("0xB0470602A64B11DA863293EBF1C0E05A");
 
-=head2 C< from_base64 >
+=head2 from_base64
 
   my $guid = Data::GUID->from_base64("sEcGAqZLEdqGMpPr8cDgWg==");
 
-=head2 C< from_data_uuid >
+=head2 from_data_uuid
 
 This method returns a new Data::GUID object if given a Data::UUID value.
 Because Data::UUID values are not blessed and because Data::UUID provides no
@@ -90,6 +90,19 @@ sub from_data_uuid {
   bless \$value => $class;
 }
 
+=head1 IDENTIFYING GUIDS
+
+=head2 string_guid_regex
+
+=head2 hex_guid_regex
+
+=head2 base64_guid_regex
+
+These methods return regex objects that match regex strings of the appropriate
+type.
+
+=cut
+
 my ($hex, $base64, %type);
 
 BEGIN { # because %type must be populated for method/exporter generation
@@ -97,10 +110,16 @@ BEGIN { # because %type must be populated for method/exporter generation
   $base64 = qr{[A-Z0-9+/=]}i;
 
   %type = ( # uuid_method  validation_regex
-    string => [ 'string',     qr/\A$hex{8}-(?:$hex{4}-){3}$hex{12}\z/, ],
-    hex    => [ 'hexstring',  qr/\A0x$hex{32}\z/,                      ],
-    base64 => [ 'b64string',  qr/\A$base64{24}\z/,                     ],
+    string => [ 'string',     qr/\A$hex{8}-?(?:$hex{4}-?){3}$hex{12}\z/, ],
+    hex    => [ 'hexstring',  qr/\A0x$hex{32}\z/,                        ],
+    base64 => [ 'b64string',  qr/\A$base64{24}\z/,                       ],
   );
+
+  for my $key (keys %type) {
+    no strict 'refs';
+    my $subname = "$key\_guid_regex";
+    *$subname = sub { $type{ $key }[1] }
+  }
 }
 
 # provided for test scripts
@@ -110,7 +129,7 @@ sub _install_from_method {
   my ($type, $alien_method, $regex) = @_;
   my $alien_from_method = "from_$alien_method";
 
-  my $our_from_code = sub { 
+  my $our_from_code = sub {
     my ($class, $string) = @_;
     $string ||= q{}; # to avoid (undef =~) warning
     Carp::croak qq{"$string" is not a valid $type GUID} if $string !~ $regex;
@@ -125,7 +144,7 @@ sub _install_as_method {
 
   my $alien_to_method = "to_$alien_method";
 
-  my $our_to_method = sub { 
+  my $our_to_method = sub {
     my ($self) = @_;
     $_uuid_gen->$alien_to_method( $self->as_binary );
   };
@@ -154,7 +173,7 @@ sub _from_multitype {
     if (my $ref = ref $value) {
       Carp::croak "a $ref reference is not a valid GUID $what"
     }
-    
+
     for my $type (@$types) {
       my $from = "from_$type";
       my $guid = eval { $class->$from($value); };
@@ -165,7 +184,7 @@ sub _from_multitype {
   }
 }
 
-=head2 C< from_any_string >
+=head2 from_any_string
 
   my $string = get_string_from_ether;
 
@@ -184,7 +203,7 @@ BEGIN { # possibly unnecessary -- rjbs, 2006-03-11
   });
 }
 
-=head2 C< best_guess >
+=head2 best_guess
 
   my $value = get_value_from_ether;
 
@@ -207,7 +226,7 @@ BEGIN { # possibly unnecessary -- rjbs, 2006-03-11
 
 These methods return various string representations of a GUID.
 
-=head2 C< as_string >
+=head2 as_string
 
 This method returns a "traditional" GUID/UUID string representation.  This is
 five hexadecimal strings, delimited by hyphens.  For example:
@@ -216,14 +235,14 @@ five hexadecimal strings, delimited by hyphens.  For example:
 
 This method is also used to stringify Data::GUID objects.
 
-=head2 C< as_hex >
+=head2 as_hex
 
 This method returns a plain hexadecimal representation of the GUID, with a
 leading C<0x>.  For example:
 
   0xB0470602A64B11DA863293EBF1C0E05A
 
-=head2 C< as_base64 >
+=head2 as_base64
 
 This method returns a base-64 string representation of the GUID.  For example:
 
@@ -233,7 +252,7 @@ This method returns a base-64 string representation of the GUID.  For example:
 
 =head1 OTHER METHODS
 
-=head2 C< compare_to_guid >
+=head2 compare_to_guid
 
 This method compares a GUID to another GUID and returns -1, 0, or 1, as do
 other comparison routines.
@@ -249,7 +268,7 @@ sub compare_to_guid {
   $_uuid_gen->compare($self->as_binary, $other_binary);
 }
 
-=head2 C< as_binary >
+=head2 as_binary
 
 This method returns the packed binary representation of the GUID.  At present
 this method relies on Data::GUID's underlying use of Data::UUID.  It is not
@@ -282,23 +301,23 @@ fully qualified name is incorrect.
 
 =cut
 
-=head2 C< guid >
+=head2 guid
 
 This routine returns a new Data::GUID object.
 
-=head2 C< guid_string >
+=head2 guid_string
 
 This returns the string representation of a new GUID.
 
-=head2 C< guid_hex >
+=head2 guid_hex
 
 This returns the hex representation of a new GUID.
 
-=head2 C< guid_base64 >
+=head2 guid_base64
 
 This returns the base64 representation of a new GUID.
 
-=head2 C< guid_from_anything >
+=head2 guid_from_anything
 
 This returns the result of calling the C<L</from_any_string>> method.
 
@@ -330,7 +349,7 @@ sub _curry_class {
 my %exports;
 BEGIN {
   %exports
-    = map { my $method = $_; $_ => sub { _curry_class($_[0], $method) } } 
+    = map { my $method = $_; $_ => sub { _curry_class($_[0], $method) } }
     ((map { "guid_$_" } keys %type), 'guid');
 }
 
@@ -1,9 +1,8 @@
 #!perl
-
 use strict;
 use warnings;
 
-use Test::More tests => 31;
+use Test::More 0.88;
 
 BEGIN { use_ok('Data::GUID'); }
 
@@ -12,25 +11,25 @@ isa_ok($guid, 'Data::GUID');
 
 like(
   $guid->as_string,
-  Data::GUID->__type_regex('string'),
+  Data::GUID->string_guid_regex,
   "GUID as_string looks OK",
 );
 
 like(
   "$guid",
-  Data::GUID->__type_regex('string'),
+  Data::GUID->string_guid_regex,
   "stringified GUID looks OK",
 );
 
 like(
   $guid->as_hex,
-  Data::GUID->__type_regex('hex'),
+  Data::GUID->hex_guid_regex,
   "GUID as_hex looks OK",
 );
 
 like(
   $guid->as_base64,
-  Data::GUID->__type_regex('base64'),
+  Data::GUID->base64_guid_regex,
   "GUID as_hex looks OK",
 );
 
@@ -40,15 +39,6 @@ ok(
 );
 
 {
-  my $other_guid = Data::GUID->new;
-
-  ok(
-    ($guid <=> $other_guid) != 0,
-    "guid is not equal to a new guid",
-  );
-}
-
-{
   my $non_guid_value = 10;
 
   is(
@@ -73,7 +63,6 @@ ok(
   }
 }
 
-
 for my $type (qw(hex string base64)) {
   my $as   = "as_$type";
   my $from = "from_$type";
@@ -93,6 +82,16 @@ for my $type (qw(hex string base64)) {
     like($@, qr/not a valid $type/, "invalid input to $from croaks");
   }
 
-  like($guid_str, Data::GUID->__type_regex($type), "guid_$type method ok");
+  my $re_method = "$type\_guid_regex";
+  like($guid_str, Data::GUID->$re_method, "guid_$type method ok");
+}
+
+{
+  my $guid = Data::GUID->new;
+  my $str  = $guid->as_string;
+  $str =~ s/-//g;
+  my $copy = Data::GUID->from_string($str);
+  is($guid->as_string, $copy->as_string, "we can from_string a dash-less str");
 }
 
+done_testing;